//
//  ActivityTableViewCell.m
//  UI_豆瓣项目
//
//  Created by dllo on 15/10/27.
//  Copyright (c) 2015年 关业达. All rights reserved.
//

#import "ActivityTableViewCell.h"
#import "UIImageView+WebCache.h"
#import "AppTools.h"
@implementation ActivityTableViewCell

- (void)dealloc
{
    [_wisCountLabel release];
    [_parCountLabel release];
    [_catNameLabel release];
    [_endTimeLabel release];
    [_beginTimeLabel release];
    [_addressLabel release];
    [_titleLabel release];
    [_movieImageView release];
    [super dealloc];
}


// 重写初始化
- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        [self createSubview];
    }
    return self;
}

// 布局子视图
- (void)createSubview
{
    UIImageView *imageView1 = [[UIImageView alloc] initWithFrame:CGRectMake(10, 15, 355, 160)];
    [imageView1 setImage:[UIImage imageNamed:@"bg_eventlistcell.png"]];
    [self.contentView addSubview:imageView1];
    [imageView1 release];
    
    
    UIImageView *imageView2 = [[UIImageView alloc] initWithFrame:CGRectMake(15, 40, 345, 130)];
    [imageView2 setImage:[UIImage imageNamed:@"bg_share_large.png"]];
    [self.contentView addSubview:imageView2];
    [imageView2 release];
    
    UIImageView *imageView3 = [[UIImageView alloc] initWithFrame:CGRectMake(30, 50, 20, 20)];
    [imageView3 setImage:[UIImage imageNamed:@"icon_date.png"]];
    [self.contentView addSubview:imageView3];
    [imageView3 release];
    
    UIImageView *imageView4 = [[UIImageView alloc] initWithFrame:CGRectMake(30, 75, 20, 20)];
    [imageView4 setImage:[UIImage imageNamed:@"icon_spot.png"]];
    [self.contentView addSubview:imageView4];
    [imageView4 release];
    
    UIImageView *imageView5 = [[UIImageView alloc] initWithFrame:CGRectMake(30, 100, 20, 20)];
    [imageView5 setImage:[UIImage imageNamed:@"icon_catalog.png"]];
    [self.contentView addSubview:imageView5];
    [imageView5 release];
    
    
    
    
    self.movieImageView = [[UIImageView alloc] initWithFrame:CGRectMake(270, 43, 75, 110)];
    self.movieImageView.backgroundColor = [UIColor yellowColor];
    [self.contentView addSubview:self.movieImageView];
    [_movieImageView release];
    
    self.titleLabel = [[UILabel alloc] initWithFrame:CGRectMake(15, 20, 150, 15)];
//    self.titleLabel.backgroundColor = [UIColor redColor];
    [self.contentView addSubview:self.titleLabel];
    [_titleLabel release];
    
    self.beginTimeLabel = [[UILabel alloc] initWithFrame:CGRectMake(55, 50, 200, 20)];
//    self.beginTimeLabel.backgroundColor = [UIColor redColor];
    [self.contentView addSubview:self.beginTimeLabel];
    [_beginTimeLabel release];

    
    self.addressLabel = [[UILabel alloc] initWithFrame:CGRectMake(55, 75, 200, 20)];
//    self.addressLabel.backgroundColor = [UIColor redColor];
    [self.contentView addSubview:self.addressLabel];
    [_addressLabel release];
    
    
    self.catNameLabel = [[UILabel alloc] initWithFrame:CGRectMake(100, 100, 150, 20)];
//    self.catNameLabel.backgroundColor = [UIColor redColor];
//    self.catNameLabel.text = @"类型:";
    [self.contentView addSubview:self.catNameLabel];
    UILabel *lable1 = [[UILabel alloc] initWithFrame:CGRectMake(55, 100, 200, 20)];
    lable1.text = @"类型:";
    [self.contentView addSubview:lable1];
    [lable1 release];
    [_catNameLabel release];
    
    self.wisCountLabel = [[UILabel alloc] initWithFrame:CGRectMake(100, 140, 80, 20)];
//    self.wisCountLabel.text = @"感兴趣:";
    [self.contentView addSubview:self.wisCountLabel];
    UILabel *lable2 = [[UILabel alloc] initWithFrame:CGRectMake(40, 140, 80, 20)];
    lable2.text = @"感兴趣:";
    [self.contentView addSubview:lable2];
    [lable2 release];
    [_wisCountLabel release];
    
    self.parCountLabel = [[UILabel alloc] initWithFrame:CGRectMake(200, 140, 80, 20)];
//    self.parCountLabel.text = @"参加:";
    [self.contentView addSubview:self.parCountLabel];
    UILabel *lable3 = [[UILabel alloc] initWithFrame:CGRectMake(160, 140, 80, 20)];
    lable3.text = @"参加:";
    [self.contentView addSubview:lable3];
    [lable3 release];
    [_parCountLabel release];
    
}

// 重写setter方法

- (void)setAActivity:(Activity *)aActivity
{
    if (_aActivity != aActivity) {
        [_aActivity release];
        _aActivity = [aActivity retain];
    }
    self.titleLabel.text = _aActivity.title;
    self.addressLabel.text = _aActivity.address;
    self.beginTimeLabel.text = _aActivity.begin_time;
    self.catNameLabel.text = _aActivity.category_name;
    self.parCountLabel.text = [NSString stringWithFormat:@"%@",_aActivity.participant_count];
    self.wisCountLabel.text = [NSString stringWithFormat:@"%@",_aActivity.wisher_count];
    //self.movieImageView.image = _aActivity.image;
    
    NSURL *url = [NSURL URLWithString:self.aActivity.Aimage];
    [self.movieImageView sd_setImageWithURL:url placeholderImage:[UIImage imageNamed:@"1.jpg"]];
    
    
}











































- (void)awakeFromNib {
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
